home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
THINKC
/
5
/
PIXELWOR
/
CPIXELWO.C
< prev
next >
Wrap
Text File
|
1992-01-01
|
7KB
|
226 lines
/******************************************************************************
CPixelWorldPane.c
Pixel World Pane Class, Version 1.0 (SUPERCLASS = CBitMapPane)
__________________________________________________________________________
Ñ Description
The CPixelWorldPane class is a subclass of CBitMapPane (THINK Class
Library 1.1) which uses a CPixelWorld to maintain a pane based on a
color offscreen drawing environment. An offscreen color graphics
device (GDevice) and an offscreen color graphics port (CGrafPort) are
used to maintain the offscreen world. This implementation supports
standard pixel depths of 1,2,4 and 8 bits. Pixel depths of 16 and 32
are not supported since the current implementation of CPixelWorld
does not rely on 32-Bit QuickDraw features.
After creating an instance of the CPixelWorldPane class, initilaze the
pane by calling the IPixelWorldPane() method with the same parameters
that you normally pass to IPane() to initialize a CPane object, plus an
additional two parameters:
(1) LongRect *aBounds
This is the bounds rectangle for the offscreen world.
(2) CPixelWorld *aPixelWorld
This is the pixel world which will be used to maintain the
offscreen image. You can create the pixel world yourself with
your own image and color table, or have a blank world created
for you by passing NULL. If you pass NULL, the pixel depth of the
blank world will be set to the maximum pixel depth of all screens
that are currently active on your system. A default color table
for that pixel depth will be used for the blank offscreen world.
The GetPixelWorld() method returns a reference to the CPixelWorld
associated with the CPixelWorldPane. The SetPixelWorld() method
allows you to assign a CPixelWorld to a CPixelWorldPane. Before you
change the CPixelWorld associated with a CPixelWorldPane, call
GetPixelWorld() and dispose of the CPixelWorld currently associated
with the pane.
The Draw() and Dispose() methods of the CBitMapPane class have been
overridden. Use these methods as you would the corresponding methods
of the superclass.
Ñ Version History
__________________________________________________________
Release Version: 1.0
Release Date: January 1, 1992
Implemented By: Vincent R. Vann, Jr.
1901 Brickell Ave, B-410
Miami, Florida 33129 USA
Compuserve Address: 76530,1242
Internet Address: vvann@umbio.med.miami.edu
(129.171.65.204)
__________________________________________________________
Ñ License Agreement
All portions of this source code are property of Vincent R. Vann, Jr.
I, Vincent R. Vann, Jr., grant you the right to freely distribute this
source code and to use all or part of this source code in all software
including commercial, freeware, shareware and private applications.
However, all software that uses any part of or all of this source code
must display a copyright notice indicating that either all of or
portions of this source code are used in the software. I also grant
you permission to alter and make improvements to this source code, but
only if all modifications are returned to me by whatever means are
available, either in written or electronic form. You must also accept
that I retain the right to include any part of your modifications or
all of your modifications in future releases of this source code. The
description and version history sections above may be ammended for
documentation purposes. This license agreement and the copyright
notice below must be maintained intact and must be included with all
distributions of this source code at all times.
This implementation is based in part on material copyrighted by Apple
Computer, Inc. and Symantec Corporation.
Copyright ⌐ 1992 Vincent R. Vann, Jr. All rights reserved.
******************************************************************************/
#include "CPixelWorldPane.h"
#include "Exceptions.h"
#include "Global.h"
#include "LongQD.h"
/**** C O N S T R U C T I O N / D E S T R U C T I O N M E T H O D S ****/
/******************************************************************************
IPixelWorldPane
Initialize a PixelWorldPane object
******************************************************************************/
void CPixelWorldPane::IPixelWorldPane(
CView *anEnclosure,
CBureaucrat *aSupervisor,
short aWidth,
short aHeight,
short aHEncl,
short aVEncl,
SizingOption aHSizing,
SizingOption aVSizing,
LongRect *aBounds,
CPixelWorld *aPixelWorld)
{
GDHandle gdh;
PixMapHandle pmap;
Rect r;
short pixelDepth;
CPanorama::IPanorama( anEnclosure, aSupervisor,
aWidth, aHeight, aHEncl, aVEncl, aHSizing, aVSizing);
bounds = *aBounds;
position.h = bounds.left;
position.v = bounds.top;
itsBitMap = NULL;
itsPixelWorld = NULL;
if (aPixelWorld != NULL) /* Use the existing pixel world */
{
itsPixelWorld = aPixelWorld;
}
else /* Create a default pixel world */
{
if (gSystem.hasColorQD) /* World has color */
{
r = (**GrayRgn).rgnBBox; /* Get rectangle that covers all screens */
gdh = GetMaxDevice( &r); /* Get device with maximum pixel depth */
pmap = (**gdh).gdPMap; /* Get handle to devices pixel map */
pixelDepth = (**pmap).pixelSize; /* Grab its pixel depth setting */
if (pixelDepth > 8) pixelDepth = 8; /* Pixel depths > 8 are not allowed */
}
else /* World is black and white */
{
pixelDepth = 1; /* Use a pixel depth of 1 */
}
LongToQDRect( aBounds, &r);
itsPixelWorld = new(CPixelWorld);
itsPixelWorld->IPixelWorld( pixelDepth, &r, NULL, NULL, 0);
}
autoRefresh = FALSE;
}
/******************************************************************************
Dispose {OVERRIDE}
Dispose of a PixelWorldPane
******************************************************************************/
void CPixelWorldPane::Dispose()
{
if (itsPixelWorld != NULL) itsPixelWorld->Dispose();
inherited::Dispose();
}
/******************************************************************************
SetPixelWorld
Specify the PixelWorld associated with a PixelWorldPane
******************************************************************************/
void CPixelWorldPane::SetPixelWorld(
CPixelWorld* aPixelWorld)
{
itsPixelWorld = aPixelWorld;
}
/******************************************************************************
GetPixelWorld
Return a reference to the PixelWorld associated with a PixelWorldPane
******************************************************************************/
CPixelWorld* CPixelWorldPane::GetPixelWorld()
{
return( itsPixelWorld);
}
/******************************************************************************
Draw {OVERRIDE}
Draw a PixelWorldPane
******************************************************************************/
void CPixelWorldPane::Draw(
Rect *area)
{
LongRect lBounds, lArea;
Rect bounds;
if (itsPixelWorld != NULL)
{
itsPixelWorld->GetBounds( &lBounds);
LongToQDRect( &lBounds, &bounds);
SectRect(area, &bounds, area);
QDToFrameR( area, &lArea);
itsPixelWorld->CopyFrom( &lArea, &lArea, NULL);
}
}